package com.jielin.handling.service.room.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.jielin.handling.entity.room.RoomRecord;
import com.jielin.handling.mapper.room.RoomRecordMapper;
import com.jielin.handling.service.room.RoomRecordService;
import com.jielin.handling.util.StringUtil;

@Service
public class RoomRecordServiceimpl implements RoomRecordService {
	@Autowired
	private RoomRecordMapper roomRecordMapper;

	@Override
	public List<RoomRecord> findSuspectRecord(String suspectid, String leaveType) {
		if (StringUtil.isEmpty(suspectid) || StringUtil.isEmpty(leaveType)) {
			return null;
		}
		return roomRecordMapper.findSuspectRecord(suspectid, leaveType);
	}

	@Override
	public String addSuspectRecord(RoomRecord roomRecord) {
		roomRecord.setId(StringUtil.generatorUUID());
		if (StringUtil.isEmpty(roomRecord.getLeaveType())) {
			roomRecord.setLeaveType("2");
		}
		roomRecordMapper.addSuspectRecord(roomRecord);
		return roomRecord.getId();
	}

	@Override
	public int addEndSuspectRecord(String leaveallcase, String roomrecordid) {
		return roomRecordMapper.updateRoomRecord(leaveallcase, roomrecordid);
	}

	@Override
	public int addEndSuspectRecord(String roomrecordid) {
		return roomRecordMapper.updateRoomRecordLeave(roomrecordid);
	}

	@Override
	public RoomRecord findLastRommRecordByRoomId(String roomId, String policeId) {
		return roomRecordMapper.findLastRommRecordByRoomId(roomId, policeId);
	}
}
